Method for compressing/decompressing structure documents

ABSTRACT

The invention concerns a method for compressing and decompressing a structured document, associated with at least a tree diagram structure defining a document structure and comprising nested structure elements, associated with a type of information, and representing sets of data, the method comprising steps which consists in: performing a syntactic analysis of the structure diagram and standardizing it so as to obtain a single predefined sequence of the elements of the diagram; compiling the standardized diagram to obtain finite automata, each automaton comprising states interconnected by transitions respectively representing the elements of the structure; and compressing the document, and executing at least a compression algorithm associated with a type of information, when a set of data having the type of information is encountered in the document.

[0001] The present invention relates to a method for compressing/decompressing structured documents.

[0002] It applies particularly, but not exclusively, to the transmission of documents such as images or image sequences, video or sound data, via digital data transmission networks, and to the storage of such documents.

[0003] There are currently in existence a number of digital document compression algorithms. Some compression algorithms are designed to process the document's binary data directly, without taking account of the data type. These algorithms have the advantage of being able to process any document, but are ineffective (low compression rate) in processing bulky documents, which are generally of the sound or image type.

[0004] Furthermore other compression algorithms are known which are more efficient, but specially adapted to one data type, for example image or sound, with the result that they cannot be used or are ineffective if they are applied to documents which do not exclusively contain data for which they are designed.

[0005] Increasingly however, the documents being used and circulating on data transmission networks contain several information types integrated in one structure.

[0006] A structured document is a collection of data sets each associated with a type, and arranged together according to mainly hierarchical relationships. These documents employ a structuring language such as SGML, HTML, XML, making it possible particularly to distinguish the different data sets composing the document. In contrast, in a so-called linear document, the document's content information is mixed with the presentation and typing information.

[0007] A structured document thus includes locators or markers separating the different data sets of the document. In the case of SGML, XML or HTML formats, these locators known as “tags” are of the form “<XXXX> and “</XXXX>”, the first marker indicating the start of the data set “XXXX” and the second the end of this set. A data set may be composed of several lower level data sets. In this way, a structured document has a hierarchical or tree structure schema, each node representing a data set and being connected to a higher hierarchical level node representing a data set which contains the lower level data sets. The nodes located at the end of a branch of this tree structure represent data sets containing data of a predefined type, which cannot be broken down into data subsets.

[0008] A structured document is generally associated with what is called a structure schema setting out in rule form the structure and type of information of each data set of the document. A schema is constituted by nested groups of data set structures, these groups being for example ordered sequences, alternative element groups or necessary element groups, sequenced or non-sequenced.

[0009] A structured document is thus associated with a structure schema and contains separation markers represented in the form of textual or binary data, these markers delimiting data sets which are themselves able to contain other data sets delimited by markers. The result is that a document structured in this way is able to include not only textual data, but also any other type of information (for example sound data, images, etc.). Consequently the specific compression algorithms of one particular type of data are ineffective and ill adapted in respect of processing this type of document.

[0010] The purpose of the present invention is to remove these drawbacks. To this end, it proposes a method for compressing and decompressing a structured document associated with at least one tree structure schema defining a structure of the document and including nested structure elements representing data sets, the structure elements being distributed in three categories, namely structured root elements broken down into structured or unstructured groups of elements and base elements corresponding to the lowest level elements in the structure, each base element and root element being associated with an information type.

[0011] According to the invention, at least one information type of the base elements is first associated with an adapted compression algorithm, the method including the following steps:

[0012] performing a syntactic analysis of the document's structure schema and normalizing it so as to obtain a single predefined sequence of the structure elements of the schema,

[0013] compiling the normalized structure schema to obtain one finite automaton per root element, each automaton including states interconnected by transitions respectively representing the structure elements, and

[0014] compressing the structured document including executing the finite automata on the document, and executing the compression algorithm when a data set having an information type associated with said algorithm is encountered in the document to be compressed.

[0015] By compiling the structure schema, the structure of the document is represented in a very compact way, and given that each data set corresponding to a base structure element is associated with an information type, it may be processed by the compression algorithm that is best adapted to its type. In this way, if the document contains for example textual data, images, sound data, this data is perfectly located in the structured document, and associated with a low level structure element and a type. When the automata are executed, they will detect the presence of data sets having a base type associated with a compression algorithm and invoke successively the algorithms corresponding to this data so as to obtain corresponding binary information sequences which are inserted as they arise into the binary document resulting from the compression.

[0016] Furthermore, in the case of a data transmission, if the documents transmitted always have the same structure schema, it is not necessary to transmit this at each document transmission, giving an additional gain in terms of the compression rate obtained by using the method according to the invention. It is even pointless to transmit it when the schema is previously known to the document's addressee. For example if it is an HTML document, there is never a need, even the first time, to encode the document schema.

[0017] By finite automaton must be understood a set of states, each state being associated with a set of input events and a transition function which determines for each input event the set of active states of the automaton. Given this definition, a number of representations may be imagined, involving code conversion tables for example, on the basis of one table per state indicating, for each input event, the table corresponding to the next state, or again correspondence tables, on the basis of one table per automaton having as many lines and columns as there are states in the automaton, with each box of the table containing the description of the transition between the two corresponding states.

[0018] When decompressing, the structure schema is processed in the same way so as to determine the automata used for compression and to analyze the content of the compressed document for the purpose of reconstituting a document in the original format having a structure which is at least equivalent, if not identical, with decompression algorithms corresponding to the compression algorithms used during compression being executed to restore the original data sets from the binary information sequences located in the compressed document.

[0019] Where the structure schema is to be transmitted with the document, the method according to the invention includes advantageously a step of transmitting the structure schema which may be the original, or that obtained after transformation and normalization or again that obtained after compilation.

[0020] According to one particularity of the invention, each data set is located in the compressed document so as to enable direct access to a particular information element, without it being necessary to decompress the whole document, or the data sets preceding the set to be decompressed.

[0021] According to another particularity of the invention, each structure schema element is furthermore associated with a set of possible numbers of occurrences, indicating the number of times that a data set having this structure element can appear in the data set of immediately higher level to which it belongs.

[0022] The process according to the invention may include a step of optimizing the document's structure schema consisting in reducing the number of hierarchical levels of groups of structure elements. This optimization makes it possible to simplify the structure schema but renders the compression process less efficient.

[0023] One preferred mode of implementing the method according to the invention will be described below, in a non-restrictive way, with reference to the appended drawings in which:

[0024]FIG. 1 represents in the form of a block diagram the links between the different steps of the method according to the invention;

[0025]FIGS. 2a, 2 b and 2 c show graphically a structure schema in form of a tree;

[0026]FIG. 3 shows a structure schema obtained by applying a reduction method according to the invention to the structure schema shown in FIG. 2;

[0027]FIGS. 4a, 4 b and 4 c show a structure schema obtained by applying another reduction method according to the invention to the structure schema shown in FIG. 2;

[0028]FIGS. 5a to 5 c show respectively three finite automata obtained and used by the method according to the invention;

[0029]FIG. 6 shows another automaton illustrating an optimization method used by the method according to the invention;

[0030]FIGS. 7a and 7 b show two automata obtained by using the process according to the invention from a particular structure schema; and

[0031]FIG. 8 shows the application of a reduction method to the automata shown in FIGS. 7a and 7 b.

[0032]FIG. 1 shows the links between the different steps of the method according to the invention.

[0033] This method is designed to process a structured document constituted by a structure schema 1 defining the document's structure and by the document's structured data.

[0034] In the XML Schema language, a structure schema has for example the following form: <element name=″C″> <complexType> <attribute name=″a2″ required=false type=″boolean″/> <attribute name=″a1″ required=true type=″integer″/> <Group order=choice> <element name=″A″ type=″TA″ minOccurs=1 maxOccurs=1/> <element name=″B″ type=″TB″ minOccurs=1 maxOccurs=1/> </Group> </complexType> </element>

[0035] This schema shows that the element named “C” has a complex structure constituted by a first element named “a2” of the Boolean type which is optional, a second element named “a1” of the integer type which is always present in the structure, and a group of alternative elements named “A” and “B” of respective types “TA” and “TB”, one of these two elements being present on a single occasion in the structure.

[0036] Types “TA” and “TB” are defined in the document's structure schema by a similar formulation.

[0037] Generally speaking, the following element groups are used to define a document's structure:

[0038] SEQ: which defines a list of sequenced elements which must all appear in the document and in the sequence indicated,

[0039] CHO: which defines a set of alternative elements, a single element of the group having to appear,

[0040] ET: which defines a set of elements which must all appear in the document in some sequence or other which is not be modified,

[0041] ET_(NO): which defines a set of elements which must all be present in the document in some sequence or other which is of no importance, and

[0042] ANY: which includes some element or other among all the possible elements which can be found in the document.

[0043] According to the invention, this formulation is analyzed and transformed at step 11 of the method so as to obtain syntax trees 4, on the basis of one tree per structure element. The syntax tree corresponding to the structure element TC is symbolized by the following formula: $\begin{matrix} \left. {TC}\rightarrow\left( {\left( {{{{a\quad 1_{\{{int}\}}^{1\quad \ldots \quad 1}}\quad\&}\quad}_{no}a\quad 2_{\{{bool}\}}^{0\quad \ldots \quad 1}} \right)^{1\quad \ldots \quad 1},\left( {A_{\{{TA}\}}^{1\quad \ldots \quad 1}\left. B_{\{{TB}\}}^{1\quad \ldots \quad 1} \right)^{1\quad \ldots \quad 1}} \right)^{1\quad \ldots \quad 1}} \right. \right. & (1) \end{matrix}$

[0044] wherein:

[0045] “→” shows that TC is the name given to the structure defined after this symbol,

[0046] “( )” shows the priorities with which the groups of elements are to be read,

[0047] “,” corresponds to a group of elements of the sequence type (SEQ),

[0048] “|” represents a group of alternative elements (CHO)

[0049] “&” represents a group of ET type elements

[0050] “&_(NO)” represents a group of non-sequenced ET type elements

[0051] “{}” associates with an element a structure element name or a base type (for example integer or Boolean), and

[0052] “A^(x . . . y)” shows that the element A is repeated by x to y times in the document, y being able to be equal to “*” representing an indeterminate value.

[0053] This formulation also uses the symbol “$” which represents any element (ANY).

[0054] The formula (1) may be represented by the tree shown in FIG. 2c, this tree including a root element “TC” 43 constituted by a single occurrence of a sequence type group 44. This group includes a single occurrence of a non-sequenced “ET” type group 45 and a single occurrence of an alternative group 46.

[0055] The group 45 being constituted by a single occurrence of an integer named “a1” and of a Boolean named “a2”, and the group 46 including a single occurrence of an element named “A” of the “TA” type and an element “B” of the “TB” type.

[0056] Types “TA” and “TB” obtained in step 11 are for example given by the following formulae: $\begin{matrix} \left. {TA}\rightarrow\left( {\left( {{{{a\quad 3_{\{{int}\}}^{1\quad \ldots \quad 1}}\quad\&}\quad}_{no}a\quad 4_{\{{int}\}}^{0\quad \ldots \quad 1}} \right)^{1\quad \ldots \quad 1},\left( {X_{\{{TC}\}}^{1\quad \ldots \quad 1},Y_{\{{TC}\}}^{1\quad \ldots \quad 1}} \right)^{1\quad \ldots \quad 1}} \right)^{1\quad \ldots \quad 1} \right. & (2) \\ \left. {TC}\rightarrow\left( \left( {{a\quad 1_{\{{int}\}}^{1\quad \ldots \quad 1}},{a\quad 5_{\{{bool}\}}^{0\quad \ldots \quad 1}}} \right)^{1\quad \ldots \quad 1} \right. \right. & (3) \end{matrix}$

[0057] and represented by the trees shown in FIGS. 2a and 2 b respectively.

[0058] The type “TA” 31 includes a single sequence type group 32 constituted by two single groups 33, 34, of the ET and SEQ type respectively. The group 33 includes two single occurrences of the integer type, named “a3” and “a4” respectively. The group 34 includes two single occurrences of the type “TC”, named “X” and “Y” respectively.

[0059] The type “TB” 39 is constituted by a single sequence type group 40, which includes two Booleans named “a1” and “a5” respectively.

[0060] Although in the preceding description the name of each element and its type are distinguished, the method according to the invention applies also to structuring languages which make no such distinction.

[0061] Furthermore, the structure elements must be determinist in other words an element must not be able to be interpreted in several different ways. For example, in the schema “(a | (a, b))”, where “a” appears, it is not known whether “b” must appear after it. To this end, there are algorithms which can be applied by the method according to the invention so as to convert a non-determinist schema into a determinist schema. Reference may be made for example to the documents [“Regular expressions into finite automata” Bruggemann-Klein, Anne, Extended Abstract in I. Simon, Hrsg, LATIN 1992, S.97-98. Springer-Verlag, Berlin 1992. Full Version in Theoretical Computer Science 120: 197-213, 1993]. Thus the schema given heretofore may for example be replaced by “(a, b^(0 . . . 1))”.

[0062] In the next step 12 of the method according to the invention, the elements of the structure schema converted into syntax trees may first of all be subjected to a process of reduction or simplification.

[0063] This reduction process consists in carrying out a general leveling by generating a single syntax tree 51 from all the trees 31, 39, and 43, as is shown in FIG. 3.

[0064] This tree in fact represents a dictionary of all the element types likely to be encountered in the document, these elements being collected together in an alternative type group 52 appearing at least once (1 . . . *) in the document. In this tree, the complex type elements “A”, “B”, “X” and “Y” are associated with an “ANY” type, and the element “a1” which appeared twice (in the elements “TB” and “TC”) with different types, is associated with a default “pcdata” type according to the XML language or with the element type in the initial document, for example “text”. The same data set may indeed be represented in several ways: for example a binary sequence may also be considered as can a character string or an integer number.

[0065] Alternatively, this reduction process consists in leveling the syntax trees locally to obtain the trees shown as 31′, 39′ and 43′ in FIGS. 4a to 4 c.

[0066] In each of these figures, the groups 32 to 34 (FIG. 2a), 40 (FIG. 2b) and 44 to 46 (FIG. 2c) have been replaced by an alternative type group 53, 54, 55, respectively, which appear at least once (1 . . . *)

[0067] The trees “TA”, “TB” and “TC” can be further subjected to an additional process to remove the ambiguities appearing in the structure schema.

[0068] At step 12, the trees “TA”, “TB” and “TC” are also subjected to a normalization process consisting in re-sequencing the schema in such a way as to obtain a single sequence of the elements of the schema. This process assigns a binary number to the different nodes of the syntax trees obtained from the previous processes. This number is used when the relevant element is compressed.

[0069] This normalization process consists in assigning to each group a signature constituted by the concatenation of the group's name with the signature of all the elements and sub-groups of the group, previously sequenced. Thus, the group 53 in FIG. 4 is associated with the signature “CHO.a3.a4.X.Y” (or “|a3.a4.X.Y”).

[0070] For this normalization process, it is considered that the sequenced groups (SEQ) are already normalized. The groups to be normalized are therefore groups of the alternative type (“CHO”), and the “ET” and “ET_(NO)” groups. This process includes the following steps for each group G composed of sub-groups g_(i) and elements e_(i):

[0071] normalizing any sub-groups g_(i) of the group G before normalizing the group G, the normalization algorithm being recursive,

[0072] arranging any elements e_(i) of the group G before the sub-groups g_(i),

[0073] arranging the elements e_(i) in a pre-defined order,

[0074] arranging the sub-groups g_(i) in the pre-defined order, and

[0075] determining the signature of the group G obtained by the concatenation of all the signatures of its components (elements and sub-groups) according to the order established as a result of the previous steps.

[0076] The pre-defined order for arranging the components of the group may be the alphanumerical order of their respective signatures, or the descending order of their minimum number of occurrences, and the components having the same minimum number of occurrences being then arranged in alphanumerical order.

[0077] It should be noted that this normalization process is not necessary in the method according to the invention. The order in which the components appear in the schema may indeed be retained.

[0078] The next step 13 in the method consists in generating finite automata 5. This process consists in generating for each syntax tree a set of base automata, on the basis of one automaton per group of the syntax tree, then in combining these base automata.

[0079] In FIG. 5a, the automaton of a sequential group (SEQ) of n elements of signatures m1, m2 to mn, of an immediately lower hierarchical level includes n+2 states numbered from 0 to n+1 symbolized in the figure by circles, each node being connected to its successor by a transition symbolized by an arc corresponding to a group element and called by the element signature, the last transition F (towards the state n+1) marking the end of the group.

[0080] In FIG. 5b, the automaton of an alternative type group (CHO) of n elements of signatures m1, m2 to mn, of an immediately lower hierarchical level includes an initial state numbered “0” and n final states numbered from 1 to n, the state 0 being connected to the final state 1 to n respectively by n transitions corresponding to the n group elements respectively.

[0081] In FIG. 5c, the automaton of an ET group of n elements of signatures m1, m2 to mn, of an immediately lower hierarchical level includes 1+n+n*(n−1)+n*(n−1)*(n−2)+ . . . +n! states representing all the possible combinations of the n elements.

[0082] An automaton of this kind may be generated by a simple algorithm such as the one which follows: E is the set of all the possible components of the group Execute Function_1 (E, initial state) Function_1 (E, state e): Repeat while E is not empty Select an element mi from E and withdraw it from E Create a state e′ and an arc joining e to e′ denoted mi Duplicate E as E′ Execute function_1 (E′, state e′) End repeat.

[0083] The automaton of a group ET_(NO) of n elements of signatures m1, m2 to mn, of an immediately lower hierarchical level may be that of an SEQ so long as it is acceptable to lose the information relating to the order of appearance of the elements in the group or it is fixed.

[0084] These automata (the case of groups of the type CHO, ET and ET_(NO)) can be optimized by applying an avoidance process of the optional elements, i.e. those with a total number of possible currencies in the form (0 . . . k).

[0085] This rule reflects the fact that each element associated with a minimum zero number of occurrences is not necessarily encoded.

[0086] As shown in FIG. 6, this process consists in adding a transition between the state “1” located immediately upstream of an optional element “2” and all the states “3” located immediately downstream of this element, this new transition being associated with the signature “m3” of the element corresponding to the state where it ends.

[0087] If one of the states located immediately downstream is also associated with an optional element, a transition must also be provided to all the states located immediately upstream of this state.

[0088] This process may be carried out using the following algorithm: Let Z be the sub-set of the nodes of the automaton for which the associated element has a minimum zero occurrence. Repeat (while the automaton is modified by the following procedure): For each element X of Z: For each incoming transition TEx of X: For each outgoing transition TSx of X: 1.Create a new transition N connecting the source node of the transition TEx and the destination node of the transition TSx. The transition is marked by the value of the arc TSx. 2.If an identical transition does not already exist in the graph, add it to the graph End for End for End for End repeat

[0089] It should be noted that the automata thus generated for one structure schema are nested in each other. Indeed, in the automata corresponding to the schema example shown in FIG. 2, when the type TC (elements X and Y) is encountered in the automaton corresponding to the type TA 31, the automaton corresponding to the type TC 43 is fully executed before proceeding with the execution of the automaton corresponding to the type TA.

[0090] The next step 14 of the method according to the invention consists in reducing and converting the automata previously obtained.

[0091] It is thus possible to merge the automata of the same syntax tree (and not automata of different trees which invoke each other) in the manner explained with reference to FIGS. 7a and 7 b.

[0092] These figures show the automata which have been generated in accordance with the method according to the invention from the structure element (a₁ ^(0 . . . *), (b₁|b₂)^(0 . . . *)). The first automaton (FIG. 7a) corresponds to the group SEQ (“,”), whereas the second automaton (FIG. 5b) corresponds to the alternative group (“51”).

[0093] When executing these automata, reaching state 2 in the first automaton activates the execution of the second automaton and reaching the final state 1 or 2 in the second automaton is followed by the pursuit of the execution of the first automaton, in other words the execution of the transition F between the state 2 and the final state 3 of the first automaton.

[0094] The process of merging the two automata makes it possible to obtain the automaton shown in FIG. 8, wherein each alternative of the CHO group is shown by a transition associated with the signature “cho.b1.b2” of the group, concatenated with the signature “b1”, “b2” of the group element appearing in the selected alternative.

[0095] During this step 14, the automata may also be subjected to a process for minimizing the number of states, for example by applying Hopcroft's algorithm, then a normalization process to obtain normalized automata 6.

[0096] Following this process, the transitions from each node are numbered from 0 to n.

[0097] The next step 15 consists in re-reading the document 2, in compressing the data which it contains by executing the automata on the structure of the document, in order to obtain a succession of binary sequences in which the compressed value of each element or base data set of the document is found. According to a first type of encoding, these binary sequences are in the form (K.N.V₁ . . . V_(N))_(e) for each element or group of elements e, N being the number of occurrences of the element e or the number of successive data sets corresponding to the element e, K being the number of the transition having made it possible to reach the element e, and V₁ . . . V_(N) the respective, possibly compressed, values of the N occurrences of the element e. If e is a group of elements, its value V is broken down into as many binary sequences (K.N.V) as it contains elements. However, in certain cases, N may be omitted, particularly when this number is fixed. The same is true for K in the event of there being only a single arc coming from a state, for example in a group of the sequence type.

[0098] A general heading of the compressed document may first be made which groups together several encoded parameters, useful for the description of the document. Such a heading may thus include a signature of the structure schema or schemas used, and a set of parameters describing the coding used, as for example:

[0099] a parameter indicating whether the coding of the length of each element is mandatory or optional or not present in the document,

[0100] a parameter indicating whether the elements may or may not be sub-typed, i.e. associated with a more precise type that their base type, and

[0101] a parameter indicating the type of coding used for the number of occurrences.

[0102] Each information element of the document may also be associated with a heading, its presence and its nature being indicated in the document heading.

[0103] The heading of an element may thus include its encoded length, in such a way as to allow, when the document is decompressed, access to a particular element without decompressing all the previous elements in the document. The element headings are inserted in the document for example just prior to encoding the value of the elements.

[0104] In a general way, compressing the document consists in reading the document sequentially, in executing the automata of the schema, which makes it possible additionally to check that the document's structure corresponds to the schema compiled.

[0105] During this process, the number of occurrences of each element appearing in the document is encoded. To this end, the following rules are applied.

[0106] Where the number of occurrences of an element e is defined by (i . . . j), the following cases may be distinguished:

[0107] If j is different from “*” and i is different from 0, the coding is broken down into two parts, namely (i.,i) and (0 . . . j-i), the first part is not encoded since this formulation specifies that i occurrences are necessary. The second part is encoded on |log₂(j-i+1)| bits.

[0108] If j is different from “*” and i is equal to 0, the number of occurrences is encoded between 1 and j, in other words on |log₂(j)| bits, since if this coding is necessary, it means that there is at least one element e in the document.

[0109] If j is equal to “*”, a coding technique such as ASN1 is used, according to which the first byte indicates the number of coding bytes, and the following bytes contain the value of the number of occurrences. It is also possible to use the high-order bit of each byte to indicate whether or not it is the last coding byte of the number of occurrences, the next seven bits of each byte being used to encode the number of occurrences.

[0110] Alternatively, another coding type may be selected wherein it is not necessary to introduce the number of occurrences of the elements of a structure schema. According to this coding type, a type called “escape” or “esc” is introduced which indicates the final state of the automata. It is therefore necessary to first apply a conversion to the automata obtained previously.

[0111] This conversion consists in adding to each state of the automata a return transition to the previous state and in adding an “esc” transition to a final state, marking the end of the execution of the automaton. The coding of the elements is then no more than the form (KV), the coding of an automaton terminating in the number K_(esc) of the transition “esc”.

[0112] In fact, this coding type is only advantageous for encoding complex forms and for elements which do not have a maximum number of occurrences. It is in particular quite adapted to encoding alternative type groups including a number of elements different from 2^(p), where p is an integer number.

[0113] This coding type may be combined with the previous type. This has only to be indicated in the heading of the compressed document and a bit assigned to the locations in the encoding where there are to be a number of occurrences.

[0114] According to the invention, at least one base type of the data sets of the document is associated with an external compression module 16. In this way, when reading the document, the respective types of the data sets encountered are analyzed, and when a type of data set is associated with an external compression module 16, this is applied to the content of the data set and the result of the compression inserted into the compressed document as a value of the corresponding data set.

[0115] External compression modules may for example apply the “mp3”standard for sound information, “jpeg” for images and “MPEG1” or “MPEG2” for video type data.

[0116] If no compression module is associated with a type of data set, a default compression module may be used or the data sets having this type recovered as they appear in the initial document.

[0117] If in the heading of the document it is indicated that encoding the length is optional or mandatory, the elements are associated with a heading in the compressed document containing the length as a number of bits of the value of the element. This particularity allows direct access to an element of the compressed document without having to decompress the elements located before in the document, by reading by means of automata only the respective lengths of these elements as far as the element being sought.

[0118] The length of the elements may be encoded in the following way.

[0119] Where in the heading of document it is indicated that encoding the length of the elements is mandatory the length L of the elements as a number of bits is calculated using the following formula:

L=8*p+h

[0120] where p represents the number of bytes (in ASN1 coding or using the high-order bits of each byte used to encode this number) used to encode the element length, and h represents the number of remaining bits of this length (h<8).

[0121] It should be noted that the external compression module 16 which is called on to encode the element value can provide this length in return.

[0122] Where encoding the length of the elements is not mandatory, the value of the first bit corresponding to the element value indicates whether the following bits represents or do not represent the element length.

[0123] If the elements can be sub-typed (indicated in the document's heading), any new types are inserted into an element heading placed in the compressed document just prior to the element value. The first bit indicates whether the element type is different or not from the expected type. In the first case, the next bits in the element heading contain the code of the new type, this code being determined by numbering all the possible sub-types of the element base type, this numbering being given by encoding the document's structure.

[0124] More precisely, a document is encoded in three main steps.

[0125] In the first step, the arcs leaving each node are numbered. This step is optional if there is only one arc leaving the node. If there are n arcs leaving, with each of these arcs is associated a number given in the order of the arcs assigned at normalization (step 14). This number is encoded over n′ bits, n′ being such that 2^(n′−1)<n≦2^(n′).

[0126] Thus, if n transitions are issued from the state E, each transition will be encoded over |log₂(n−1)|+1 bits.

[0127] In the second step, the number of occurrences of each sub-automaton is encoded as described above.

[0128] In the third step, the sub-automaton is encoded. This process may be expressed by the following algorithm:

[0129] Get into position at the start of the automaton, While the active state is not final

[0130] The arc being crossed is encoded, if necessary

[0131] The number n of occurrences is encoded, if necessary

[0132] Move around in the sub-automaton corresponding to the node reached,

[0133] This sub-automaton is encoded n times.

[0134] Go back to the initial automaton.

[0135] End While.

[0136] For example, to encode the occurrence “a₂ a₃ a₁ a₁ a₃” of the automaton (a₁|a₂|a₃)^((0 . . . *)), there are three outgoing arcs. The arcs are therefore numbered on two bits. Consequently, the result of the coding is as follows in the case where the number of occurrences is encoded: 0000 0101 01 V_(a2) 10 V_(a3) 00 V_(a1) 00 V_(a1) 10 V_(a3)

[0137] where “0000 0101” represents the binary value of the number of occurrences i.e. 5, and V_(a1), V_(a2), and V_(a3) are the values of the occurrences of a1, a2 and a3 respectively.

[0138] Where the number of occurrences is not encoded: 01 V_(a2) 10 V_(a3) 00 V_(a1) 00 V_(a1) 10 V_(a3) 11

[0139] 11 corresponding to the number of the outgoing transition “esc”.

[0140] In the example in FIGS. 7a, 7 b, encoding the occurrence “b₂ b₁ a₁” of the automaton (a₁ ^(0 . . . *),b₁|b₂)^(0 . . . *)) leads to the following result (where the states are not merged): 0000 0010 number of occurrences of the sequence (here twice) 1 encoding the arc ″cho.b₁.b₂″ 0000 0010 number of occurrences of the group ″cho.b₁.b₂″ (here twice). 1 encoding the arc b₂ in the group ″cho.b₁.b₂″ V_(b2) encoding the value b₂ 0 encoding the arc b₁ in the group ″cho.b₁.b₂″ V_(b1) encoding the value b₁ 0 encoding the arc a₁ 0000 0001 number of occurrences of a₁ V_(a1) encoding the value of a₁ 1 encoding the outgoing arc F

[0141] Where the states are merged (FIG. 8) 0000 0010 Number of occurrences of the sequence 10 Encoding the arc ″cho.b₁.b₂-b₂″ 0000 0010 Number of occurrences of the group ″cho.b₁.b₂″. V_(b2) Encoding the value b₂ 0 Encoding the arc b₁ in the group ″cho.b₁.b₂″ V_(b1) Encoding the value b₁ 00 Encoding the arc a₁ 0000 0001 Number of occurrences of a₁ V_(a1) Encoding the value of a₁ 10 Encoding the outgoing arc F

[0142] It may be necessary to re-arrange the automaton, particularly if the schema has been interpreted and re-ordered in such a way as to optimize coding in the case of the group ET_(NO).

[0143] If the attribute sequence is not useful (as in the XML language), it is possible to encode so as to re-order the element attributes in a pre-determined sequence, for example in an alphanumerical sequence, then according to whether they are required or not. This arrangement makes it possible to reduce the size of the compressed description accordingly.

[0144] The process of decompressing a document thus obtained is performed by executing steps 11 to 15 on the document's structure schema to obtain the automata, then by executing step 15′ of decoding and decompressing the document, this step consisting in running through the compressed document executing the automata obtained as a result of steps 11 to 14, in such a way as to be able to determine the type and the name of the compressed information elements encountered in the document. The values of the elements which have been obtained by means of external compression modules 16 are decompressed by means of corresponding decompression modules 16′.

[0145] It should be noted that if several documents having the same structure schema are to be processed (compressed or decompressed), steps 11 to 15 are only executed once, only steps 15 and 16 (or 15′ and 16′) having to be applied to each document to be processed. 

1. Method for compressing and decompressing a structured document, associated with at least one tree structure schema (1; 31, 39, 43) defining a structure of the document and including nested structure elements (32, 33, 34, 40, 44, 45, 46, a3, a4, X, Y, a1, a5, a1, a2, A, B) representing data sets of the document, the structure elements being distributed in three categories, namely structured root elements (31, 39, 43), groups of elements (32, 33, 34, 40, 44, 45, 46), and structured (X, Y, A, B), or unstructured (a3, a4, a1, a5, a1, a2) base elements corresponding to the lowest level elements in the structure, each base element being associated with an information type, characterized in that at least one information type of the base elements is first associated with an adapted compression algorithm (16), the method including the following steps: performing a syntactic analysis (11) of the document's structure schema, compiling (13) the normalized structure schema to obtain one finite automaton (5) per root element, each automaton including states (“0”, “1”, to “n”) interconnected by transitions (“m1”, “m2”, to “mn”) respectively representing the structure elements, and compressing (15) the structured document (2) for compression including executing the finite automata (5) on the document, and executing the compression algorithm (16) when a data set having an information type associated with said algorithm is encountered in the structured document (2).
 2. Method according to claim 1, characterized in that, for the purpose of decompressing the compressed document (10), it includes executing steps (11, 12, 13) to determine the automata (5) used for compression from the structure schema (1), executing (15′) the automata (5) on the compressed document (10) to analyze its content, for the purpose of reconstituting a document in the original format having an at least equivalent structure, decompression algorithms (16′) corresponding to the compression algorithms (16) used during compression (15) being executed to restore the data sets of the original structured document (2) from binary information sequences located in the compressed document while executing the automata.
 3. Method according to claim 1 or 2, characterized in that where the structure schema (1) is to be transmitted with the document, the method according to the invention includes a step of transmitting the structure schema (5).
 4. Method according to one of claims 1 to 3, characterized in that it includes a step of normalizing (12) the structure schema (5) of the document so as to obtain a single predefined sequence of the elements of the schema.
 5. Method according to one of claims 1 to 4, characterized in that each data set is located in the compressed document, so as to enable direct access to a particular data set, without it being necessary to decompress the data sets preceding the set to be decompressed.
 6. Method according to one of claims 1 to 5, characterized in that each structure schema element is furthermore associated with a set of possible numbers of occurrences, indicating the number of times that a data set having this structure element can appear in the data set of immediately higher level to which it belongs.
 7. Method according to one of claims 1 to 6, characterized in that it includes a step of optimizing the document's structure schema consisting in reducing the number of hierarchical levels of groups of structure elements.
 8. Method according to one of claims 1 to 7, characterized in that the compressed document (10) includes for each data set of the original document, a transition number corresponding to the structure element associated with the data set and the binary value of the compressed data set.
 9. Method according to claim 8, characterized in that in the compressed document (10), each structure element of at least a part of the structure elements of the structure schema is associated with a number of occurrences of data sets in the document.
 10. Method according to claim 8 or 9, characterized in that in the compressed document (10), the end of a group of several occurrences of data sets of the same type is located by a binary sequence representing a transition to a final state number. 